#include<bits/stdc++.h>
using namespace std;
const int N = 1e3 + 1;
int a[N];
int main(){
	int n;
	cin >> n;
	for(int i = 0; i < n; i++){
		cin >> a[i];
	}
	int lower = 0;
	int higher = 0;
	for(int j = 0; j < n; j++){
		lower = 0;
		higher = 0;
		for(int i = 0; i < n; i++){
			if(a[i] > a[j])
				higher++;
			else if(a[i] < a[j])
				lower++;
		}
		if(higher == lower)
		{
		//	cout << higher << lower << endl;
			cout << a[j] << endl;
			return 0;
		}	
	}
	cout << "-1" << endl;
	return 0;
}
